package com.dp.service.impl3;

import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dp.pojo.GameVo;
import com.dp.pojo.JsonPage;

import com.dp.pub.SysProperty;
import com.dp.pub.UtilsBean;
import com.dp.util.BookConfig;
import com.dp.util.DataMap;
import com.dp.util.ImageScalee;
import com.dp.util.InterUtil;
import com.dp.vo.TGenre;

@Service
@Transactional
public class GameServiceImpl extends BaseImpl {
	
	public int findAllGameInfoEntityCount(DataMap hashMap){
		int resultInt=0;
		JsonPage jpage=(JsonPage) hashMap.get("jpage");
		GameVo game=(GameVo) hashMap.get("game");
		String searchChid=(String)hashMap.get("searchChid");
		String sql = "select count(tc.contentid) " +
		"from t_contents tc,t_genre gen,t_service_info p,t_auditapp_content tac ";
		if(searchChid!=null&&searchChid.trim().length()>0) {
			sql += ",news_extends_channel_title nect,news_extends_channel nec,news_contenttitle nc ";
			sql += "where nect.channleid=nec.channleid and nec.channel_id='"+searchChid+"' and nect.cid=nc.cid and nc.contentid=tc.contentid " +
					"and  (tc.content_type='3' or tc.content_type='10') and tc.genre_id=gen.genre_id and tc.service_code=p.service_code and tc.contentid = tac.contentid";
		}else{
			sql+=" where (tc.content_type='3' or tc.content_type='10') and tc.genre_id=gen.genre_id and tc.service_code=p.service_code and tc.contentid = tac.contentid";
			
		}
		Object role_id = hashMap.get("role_id");
		Object user_id = hashMap.get("user_id");
		Object content_status = hashMap.get("content_status");
		Object test_status = hashMap.get("test_status");
		Object genre_id = hashMap.get("genre_id");
		Object searchcontentname = hashMap.getMapData("searchcontentname");
		String userids=(String)hashMap.get("userids");
		if(StringIsNotNull(role_id) && StringIsNotNull(user_id))
		{
			sql = sql + " AND tc.user_id='" + user_id + "'";
		}else if(userids!=null){
			sql = sql + " AND tc.user_id in (" + userids + ")";
		}
		
		if (StringIsNull(content_status)) {
		    sql = sql + " AND tc.content_status='" + content_status + "'";
		}
		if (StringIsNull(test_status)) {
		    sql = sql + " AND tc.test_status='" + test_status + "'";
		}
		if (StringIsNull(genre_id)) {
		    sql = sql + " AND tc.genre_id='" + genre_id + "'";
		}        
		if (StringIsNull(searchcontentname)) {
		    sql = sql + " AND tc.content_name like '%" + searchcontentname + "%'";
		}
		
		String sql2 = "";
		if(role_id != null && role_id.toString().compareToIgnoreCase("CHANNEL") == 0)
		{
			sql2 = "select count(distinct tc.contentid) " +
				"from t_auditapp_content tac,t_genre gen,t_service_info p,t_contents tc, " +
				"(select contentid from t_resources tr ,(SELECT ts.sourceid FROM t_user tu ,t_employee te,t_spcode ts where tu.user_id='"+user_id+"' and tu.employee_id=te.employee_id and te.sp_code=ts.spcode ) t where tr.distributorid = t.sourceid ) tt " ;
			if(searchChid!=null&&searchChid.trim().length()>0) {
				sql += ",news_extends_channel_title nect,news_extends_channel nec,news_contenttitle nc ";
				sql += "where nect.channleid=nec.channleid and nec.channel_id='"+searchChid+"' and nect.cid=nc.cid and nc.contentid=tc.contentid " +
						"and (tc.content_type='3' or tc.content_type='10') and tc.contentid=tt.contentid and tc.genre_id=gen.genre_id and tc.service_code=p.service_code and tc.contentid = tac.contentid ";
			}else{
				sql+="where (tc.content_type='3' or tc.content_type='10') and tc.contentid=tt.contentid and tc.genre_id=gen.genre_id and tc.service_code=p.service_code and tc.contentid = tac.contentid ";
			}
			
			if (StringIsNull(content_status)) {
		        sql2 = sql2 + " AND tc.content_status='" + content_status + "'";
		    }
		    if (StringIsNull(test_status)) {
		        sql2 = sql2 + " AND tc.test_status='" + test_status + "'";
		    }
		    if (StringIsNull(genre_id)) {
		        sql2 = sql2 + " AND tc.genre_id='" + genre_id + "'";
		    }        
		    if (StringIsNull(searchcontentname)) {
		        sql2 = sql2 + " AND tc.content_name like '%" + searchcontentname + "%'";
		    }
			sql = sql + " union all " + sql2;
		}
		
		try {
			resultInt=this.getOneInt();
			} catch (Exception e) {
				logger.error("findAllGameInfoEntityCount fail !!!" + e.getMessage());
				e.printStackTrace();
				
			}
		return resultInt;
	}
	
//	public List<GameVo> findAllGameInfoEntity(DataMap hashMap, Integer firstrow,
//			Integer maxrow){
//		JsonPage jpage=(JsonPage) hashMap.get("jpage");
//		GameVo game=(GameVo) hashMap.get("game");
//		String searchChid=(String)hashMap.get("searchChid");
//		String sql = "select tc.*,gen.genre_name ,p.servicename,p.service_code,p.price,tc.content_code,p.price_type,p.servicetype,p.access_no,p.content,p.order_success_msg,p.starttime," +
//		"tac.version,tac.service_count " +
//		"from t_contents tc,t_genre gen,t_service_info p,t_auditapp_content tac ";
//		if(searchChid!=null&&searchChid.trim().length()>0) {
//			sql += ",news_extends_channel_title nect,news_extends_channel nec,news_contenttitle nc ";
//			sql += "where nect.channleid=nec.channleid and nec.channel_id='"+searchChid+"' and nect.cid=nc.cid and nc.contentid=tc.contentid " +
//					"and  (tc.content_type='3' or tc.content_type='10') and tc.genre_id=gen.genre_id and tc.service_code=p.service_code and tc.contentid = tac.contentid";
//		}else{
//			sql+=" where (tc.content_type='3' or tc.content_type='10') and tc.genre_id=gen.genre_id and tc.service_code=p.service_code and tc.contentid = tac.contentid";
//			
//		}
//		Object role_id = hashMap.get("role_id");
//		Object user_id = hashMap.get("user_id");
//		Object content_status = hashMap.get("content_status");
//		Object test_status = hashMap.get("test_status");
//		Object genre_id = hashMap.get("genre_id");
//		Object searchcontentname = hashMap.getMapData("searchcontentname");
//		String userids=(String)hashMap.get("userids");
//		if(StringIsNotNull(role_id) && StringIsNotNull(user_id))
//		{
//			sql = sql + " AND tc.user_id='" + user_id + "'";
//		}else if(userids!=null){
//			sql = sql + " AND tc.user_id in (" + userids + ")";
//		}
//		
//		if (StringIsNull(content_status)) {
//		    sql = sql + " AND tc.content_status='" + content_status + "'";
//		}
//		if (StringIsNull(test_status)) {
//		    sql = sql + " AND tc.test_status='" + test_status + "'";
//		}
//		if (StringIsNull(genre_id)) {
//		    sql = sql + " AND tc.genre_id='" + genre_id + "'";
//		}        
//		if (StringIsNull(searchcontentname)) {
//		    sql = sql + " AND tc.content_name like '%" + searchcontentname + "%'";
//		}
//		
//		String sql2 = "";
//		if(role_id != null && role_id.toString().compareToIgnoreCase("CHANNEL") == 0)
//		{
//			sql2 = "select distinct  tc.channel_id  ,tc.service_code,tc.channel_name,tc.channel_comment ,tc.function_name,tc.STATUS ,tc.ordered ,tc.created_date,tc.previous_id ,tc.primal_id ,tc.LEVEL ,tc.channel_type  ,tc.channel_hot_topics ,tc.channel_classifying_label" +" ,gen.genre_name ,p.servicename,p.service_code,p.price,p.price_type,p.servicetype,p.access_no,p.content,p.order_success_msg,p.starttime," +
//				"tac.version,tac.service_count " +
//				"from t_auditapp_content tac,t_genre gen,t_service_info p,t_contents tc, " +
//				"(select contentid from t_resources tr ,(SELECT ts.sourceid FROM t_user tu ,t_employee te,t_spcode ts where tu.user_id='"+user_id+"' and tu.employee_id=te.employee_id and te.sp_code=ts.spcode ) t where tr.distributorid = t.sourceid ) tt " ;
//			if(searchChid!=null&&searchChid.trim().length()>0) {
//				sql += ",news_extends_channel_title nect,news_extends_channel nec,news_contenttitle nc ";
//				sql += "where nect.channleid=nec.channleid and nec.channel_id='"+searchChid+"' and nect.cid=nc.cid and nc.contentid=tc.contentid " +
//						"and (tc.content_type='3' or tc.content_type='10') and tc.contentid=tt.contentid and tc.genre_id=gen.genre_id and tc.service_code=p.service_code and tc.contentid = tac.contentid ";
//			}else{
//				sql+="where (tc.content_type='3' or tc.content_type='10') and tc.contentid=tt.contentid and tc.genre_id=gen.genre_id and tc.service_code=p.service_code and tc.contentid = tac.contentid ";
//			}
//			
//			if (StringIsNull(content_status)) {
//		        sql2 = sql2 + " AND tc.content_status='" + content_status + "'";
//		    }
//		    if (StringIsNull(test_status)) {
//		        sql2 = sql2 + " AND tc.test_status='" + test_status + "'";
//		    }
//		    if (StringIsNull(genre_id)) {
//		        sql2 = sql2 + " AND tc.genre_id='" + genre_id + "'";
//		    }        
//		    if (StringIsNull(searchcontentname)) {
//		        sql2 = sql2 + " AND tc.content_name like '%" + searchcontentname + "%'";
//		    }
//			sql = sql + " union all " + sql2;
//		}
//		
//		String[][] orderSS=new String[][]{
//				{"content_name","genre_name","content_type","content_status","test_status","version","service_code","price","content_code","user_id"},
//				{"tc.content_name","gen.genre_name","tc.content_type","tc.content_status","tc.test_status","tac.version","p.service_code","p.price","tc.content_code","tc.user_id"}};
//		
//		if(jpage!=null){
//			if(jpage.getSidx()!=null&&!"".equals(jpage.getSidx())){
//				for(int i=0;i<orderSS[0].length;i++){
//					if(orderSS[0][i].equals(jpage.getSidx())){
//						jpage.setSidx(orderSS[1][i]);
//						break;
//					}
//				}
//				sql+=" order by "+jpage.getSidx()+" "+jpage.getSord();
//			}
//		}
//		
//		if(firstrow!=null&&maxrow!=null){
//			sql+=" limit "+firstrow+","+maxrow+"";
//		}
//		List<GameVo> gamelist=new ArrayList<GameVo>();
//		try {
//		
//			GameVo temp=null;
//			List<Object[]> tempp=this.em.createNativeQuery(sql).getResultList();
//			for(Object[]o:tempp)
//			{
//				temp=new GameVo();
////				temp.setContentid(rs1.getString("contentid"));
////				temp.setContent_name(rs1.getString("content_name"));
////				temp.setGenre_id(rs1.getString("genre_id"));
////				temp.setGenre_name(rs1.getString("genre_name"));
////				temp.setContent_type(rs1.getString("content_type"));
////				temp.setContent_status(rs1.getString("content_status"));
////				temp.setTest_status(rs1.getString("test_status"));
////				temp.setVersion(rs1.getString("version"));
////				temp.setService_code(rs1.getString("service_code"));
////				temp.setPrice(rs1.getString("price"));
////				temp.setContent_code(rs1.getString("content_code"));
////				temp.setUser_id(rs1.getString("user_id"));
////				temp.setCause(rs1.getString("cause"));
//				gamelist.add(temp);
//			}
//			
//			} catch (Exception e) {
//				logger.error("findAllGameInfoEntity fail !!!" + e.getMessage());
//				e.printStackTrace();
//			}
//		return gamelist;
//	}
	
	//modify:add insert into news_contenttitle  news_extends_channel_title
    public boolean insertContent(DataMap hashMap) {
    	GameVo game=(GameVo)hashMap.get("game");
    	
    	UtilsBean b = new UtilsBean();
        StringBuffer sql_auditcontents = new StringBuffer();
        sql_auditcontents.append("insert into t_contents (contentid,genre_id,service_code,user_id,content_name,content_keyword,content_pubdate," +
        		"content_duration,conten_info,content_type,content_updateddate,Copyright_deadline,content_status,test_status,audituser," +
        		"pub_company,area,ordered,cause,content_code,order_success_msg) values (" );
        //t_auditcontents columns
        String content_id = b.ObjectToStringDB(game.getContentid());
        String genre_id = b.ObjectToStringDB(game.getGenre_id());
        String service_code = b.ObjectToStringDB(game.getService_code());
        String user_id = b.ObjectToStringDB(hashMap.get("user_id"));        
        String content_name = b.ObjectToStringDB(game.getContent_name());
        String content_keyword = b.ObjectToStringDB(game.getContent_keyword());
        
        String content_pubdate=null;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        if(game.getContent_pubdate()!=null){
        	content_pubdate = "'"+sdf.format(game.getContent_pubdate())+"'";
        }else{
        	Date date = new Date();
			content_pubdate = "'"+sdf.format(date)+"'";
        }
        
        String content_duration = b.ObjectToStringDB(game.getContent_duration());
        String conten_info = b.ObjectToStringDB(game.getContent_info());        
//        String contenttype = b.ObjectToStringDB("3");
        String contenttype = b.ObjectToStringDB(game.getContent_type());
        String nowtime = b.getNowTime();
        String update_date = b.ObjectToStringDB(nowtime);
        
        String Copyright_deadline = null;
        if(game.getCopyright_deadline()!=null){
        	Copyright_deadline = "'"+sdf.format(game.getCopyright_deadline())+"'";
        }else{
        	Copyright_deadline = "'2037-12-31'";
        }
        
        String content_status = b.ObjectToStringDB("new");//b.ObjectToStringDB(hashMap.get("status"));
        String test_status = b.ObjectToStringDB("0");
        String audituser = b.ObjectToStringDB(game.getAudituser());
//        String lastservice_code = service_code;// add new content lastservicecode = servicecode
        String pub_company = b.ObjectToStringDB(game.getPub_company());
        String area = b.ObjectToStringDB(game.getArea());
        String ordered = b.ObjectToStringDB(game.getOrdered());
        String cause = b.ObjectToStringDB(game.getCause());
        String content_code = b.ObjectToStringDB(game.getContent_code());
        String order_success_msg = b.ObjectToStringDB(game.getOrder_success_msg());
        sql_auditcontents.append(content_id);
        sql_auditcontents.append(",");
        sql_auditcontents.append(genre_id);
        sql_auditcontents.append(",");
        sql_auditcontents.append(service_code);
        sql_auditcontents.append(",");
        sql_auditcontents.append(user_id);
        sql_auditcontents.append(",");
        sql_auditcontents.append(content_name);
        sql_auditcontents.append(",");
        sql_auditcontents.append(content_keyword);
        sql_auditcontents.append(",");
        sql_auditcontents.append(content_pubdate);
        sql_auditcontents.append(",");
        sql_auditcontents.append(content_duration);
        sql_auditcontents.append(",");
        sql_auditcontents.append(conten_info);
        sql_auditcontents.append(",");
        sql_auditcontents.append(contenttype);
        sql_auditcontents.append(",");
        sql_auditcontents.append(update_date);
        sql_auditcontents.append(",");
        sql_auditcontents.append(Copyright_deadline);
        sql_auditcontents.append(",");
        sql_auditcontents.append(content_status);
        sql_auditcontents.append(",");
        sql_auditcontents.append(test_status);
        sql_auditcontents.append(",");
        sql_auditcontents.append(audituser);
        sql_auditcontents.append(",");
        sql_auditcontents.append(pub_company);
        sql_auditcontents.append(",");
        sql_auditcontents.append(area);
        sql_auditcontents.append(",");
       /* sql_auditcontents.append(service_code);//new content lastservice_code == service_code
        sql_auditcontents.append(",");*/
        sql_auditcontents.append(ordered);
        sql_auditcontents.append(",");
        sql_auditcontents.append(cause);
        sql_auditcontents.append(",");
        sql_auditcontents.append(content_code);
        sql_auditcontents.append(",");
        sql_auditcontents.append(order_success_msg);
        sql_auditcontents.append(")");
        
        StringBuffer sql_auditapp_content = new StringBuffer();
        sql_auditapp_content.append("insert into t_auditapp_content (contentid,strategy,language,online,version,cldc_version,midp_version," +
        		"audituser,ordered,service_count) values ("); 
        //t_auditapp_content columns:strategy,language,online,content_size,version,cldc_version,midp_version
        String strategy = b.ObjectToStringDB(game.getStrategy());
        String language = b.ObjectToStringDB(game.getLanguage());
        String online = b.ObjectToStringDB(game.getOnline());
        String version = b.ObjectToStringDB(game.getVersion());
        String cldc_version = b.ObjectToStringDB(game.getCldc_version());
        String midp_version = b.ObjectToStringDB(game.getMidp_version());
        String service_count = b.ObjectToStringDB(game.getService_count());
        if(service_count == null || service_count.equals("") || service_count.equals("null"))
        {
        	service_count = b.ObjectToStringDB("0");
        }
        sql_auditapp_content.append(content_id);
        sql_auditapp_content.append(",");
        sql_auditapp_content.append(strategy);
        sql_auditapp_content.append(",");
        sql_auditapp_content.append(language);
        sql_auditapp_content.append(",");
        sql_auditapp_content.append(online);
        sql_auditapp_content.append(",");
        sql_auditapp_content.append(version);
        sql_auditapp_content.append(",");
        sql_auditapp_content.append(cldc_version);
        sql_auditapp_content.append(",");
        sql_auditapp_content.append(midp_version);
        sql_auditapp_content.append(",");
        sql_auditapp_content.append(audituser);
        sql_auditapp_content.append(",");
        sql_auditapp_content.append(ordered);
        sql_auditapp_content.append(",");
        sql_auditapp_content.append(service_count);
        sql_auditapp_content.append(")");
        
        //update phase2  insert news_contenttitle
//        String contenticon = b.ObjectToString(hashMap.get("contenticon"));
        String contenticon = SysProperty.getPrep("sysiconid_title");
        if(contenticon == null || contenticon.equals(""))
        	contenticon = "1";
        String contenttext = "'"+InterUtil.rb.getString("src.gamename")+":"+b.ObjectToString(game.getContent_name())+"@"+InterUtil.rb.getString("src.devcompany")+":"+b.ObjectToString(game.getPub_company())
							+"@"+InterUtil.rb.getString("src.language")+":"+b.ObjectToString(game.getLanguage())+"@"+InterUtil.rb.getString("src.online")+":"+b.ObjectToString(game.getOnline())+"@"+InterUtil.rb.getString("src.version")+":"+
							b.ObjectToString(game.getVersion())+"@"+InterUtil.rb.getString("src.updatetime")+":"+nowtime+"@"+InterUtil.rb.getString("src.gameintro")+":"+
							b.ObjectToString(game.getContent_info())+"@"+InterUtil.rb.getString("src.gamesta")+":"+b.ObjectToString(game.getStrategy())+"'";
        
        String newstype = "'"+InterUtil.rb.getString("src.game")+"'";
        StringBuffer insertNewsContentTitle = new StringBuffer();
        insertNewsContentTitle.append("insert into news_contenttitle (contentid,contenttitle,contenticon,contenttext,newstype) values (");
        insertNewsContentTitle.append(content_id);
        insertNewsContentTitle.append(",");
        insertNewsContentTitle.append(content_name);
        insertNewsContentTitle.append(",");
        insertNewsContentTitle.append(contenticon);
        insertNewsContentTitle.append(",");
        insertNewsContentTitle.append(contenttext);
        insertNewsContentTitle.append(",");
        insertNewsContentTitle.append(newstype);
        insertNewsContentTitle.append(")");
        //---------
        
        String res=(String)hashMap.get("resourceid");
        String [] resid=res.split(",");
        
        String channels=(String)hashMap.get("channelids");
        String [] channelid=channels.split(",");
        
        
        //phase2
        String newChSql="insert into news_extends_channel_title(channleid,cid,contentstatus,istest,isnew)VALUES(";
        
        ArrayList<String> sqlStrList = new ArrayList<String>();
        sqlStrList.add(sql_auditcontents.toString());
        sqlStrList.add(sql_auditapp_content.toString());
        //phase2  insert news_contenttitle
        sqlStrList.add(insertNewsContentTitle.toString());
        
        for(int i=0;i<channelid.length;i++)
        {
        	sqlStrList.add(newChSql+"(select channleid from news_extends_channel where channel_id='"+channelid[i]+"'),(select LAST_INSERT_ID()),0,0,1)");
        }
        
        String tempSql="insert into t_resource_content(contentid,resourceid)VALUES( "+content_id + ",";
        for(int i=0;i<resid.length;i++)
        {
        	sqlStrList.add(tempSql+"'"+resid[i]+"')");
        }
        int serviceCountNum = Integer.parseInt(service_count.replace("'", ""));
        if(serviceCountNum > 0)
        {
	        for(int i = 1;i <= serviceCountNum; i++)
	        {
	        	StringBuffer sql_billingpoint_service = new StringBuffer();	        
		        sql_billingpoint_service.append("insert into t_billingpoint_service (contentid,billingpoint,comment,service_code) values (");
		        sql_billingpoint_service.append(content_id);
		        sql_billingpoint_service.append(",");
		        if(i<10)
		        	sql_billingpoint_service.append("'0"+i+"'");
		        else
		        	sql_billingpoint_service.append("'"+i+"'");
	        	sql_billingpoint_service.append(",");
	        	sql_billingpoint_service.append("null");
	        	sql_billingpoint_service.append(",");
	        	sql_billingpoint_service.append(b.ObjectToStringDB(hashMap.get("service_point_" + i)));
	        	sql_billingpoint_service.append(")");
	        	sqlStrList.add(sql_billingpoint_service.toString());
	        }
        }
        
//        String[] sqlStr = sqlStrList.toArray(new String[channelid.length*2+resid.length+2+serviceCountNum+1]);
        String[] sqlStr = sqlStrList.toArray(new String[sqlStrList.size()]);
        try {
            return execTransaction(sqlStr);
        } catch (Exception e) {
        	log.info(" insertAuditContent fail !!!" +e.getMessage());
        	e.printStackTrace();
            return false;
        }
    }
    
	 public boolean insertResource(DataMap hashMap) {
		 	UtilsBean b = new UtilsBean();
	        StringBuffer sqlB = new StringBuffer();
	        String resource_id = b.ObjectToStringDB(hashMap.get("resource_id"));
	        Object content_id = hashMap.get("content_id");
	        String useragent = b.ObjectToStringDB(hashMap.get("useragent"));
	        String name = b.ObjectToStringDB(hashMap.get("name"));
	        long size = b.getlong(hashMap.get("size"));
	        String type = b.ObjectToStringDB(hashMap.get("type"));
	        String spcode = b.ObjectToStringDB(hashMap.get("spcode"));
	        String url = b.ObjectToStringDB(hashMap.get("url"));
	        String format = b.ObjectToStringDB(hashMap.get("format"));
	        String distributorid = b.ObjectToStringDB(hashMap.get("distributorid"));
	        //add newformat fullpath
	        String newformat = SysProperty.getPrep("news_imageformat");
	        if(newformat == null || newformat.equals(""))
	        	newformat = "jpg";
	        if(format.lastIndexOf("_")>0)
	        	format = "'"+format.substring(format.lastIndexOf("_")+1);
	        
	        String curdate = (new java.text.SimpleDateFormat("yyyyMM")).format(new Date());
	        String fullpath = SysProperty.getPrep("uploadpath")+"/"+spcode.replace("'", "")+"/"+type.replace("'", "")+"/"+curdate+"/"+url.replace("'", "")+"."+format.replace("'", "");
	        String sql = "insert into t_resources (resourceid,name,size,type,spcode,url,format,distributorid,newformat,fullpath) VALUES ( ";
	        if(content_id != null)
	        {
	        	sql = "insert into t_resources (resourceid,contentid,name,size,type,spcode,url,format,distributorid,newformat,fullpath) VALUES ( ";
		        if(type.equals("'3'"))
		        {
		        	sql = "insert into t_resources (resourceid,contentid,useragents,name,size,type,spcode,url,format,distributorid,newformat,fullpath) VALUES ( ";
		        }
	   		}
	        sqlB.append(sql);
	        
	        sqlB.append(resource_id).append(",");
	        if(content_id != null)
	        {
		        content_id = b.ObjectToStringDB(content_id);
	        	sqlB.append(content_id).append(",");
	        	if(type.equals("'3'"))
		        {
		        	sqlB.append(useragent).append(",");
		        }
	        }
	        sqlB.append(name).append(",");
	        sqlB.append(size).append(",");
	        sqlB.append(type).append(",");
	        sqlB.append(spcode).append(",");
	        sqlB.append(url).append(",");
	        sqlB.append(format).append(",");
	        sqlB.append(distributorid).append(",");
	        sqlB.append("'"+newformat+"'").append(",");
	        sqlB.append("'"+fullpath+"'").append(")");
	        hashMap = new DataMap();
	        try {
	            return execUpdate(sqlB.toString());
	        } catch (Exception e) {
	        	log.info(" insertResource fail !!!" +e.getMessage());
	            return false;
	        }
	    }    
	 
	//modify add update news_contenttitle
	    public boolean updateAuditContent(DataMap hashMap) {
	    	GameVo game=(GameVo)hashMap.get("game");
	    	
	    	UtilsBean b = new UtilsBean();
	        String sql = "update  t_contents set ";
	        String sqlUpdateAuditApp = "update t_auditapp_content set ";
	        String content_id = b.ObjectToStringDB(game.getContentid());
//	        String employee_id = b.ObjectToStringDB(hashMap.get("employee_id"));
//	        String user_id = b.ObjectToStringDB(hashMap.get("user_id"));
			String content_name = b.ObjectToStringDB(game.getContent_name());
	        String genre_id = b.ObjectToStringDB(game.getGenre_id());        
			String content_status = b.ObjectToStringDB("new");
			
		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			String content_pubdate=null;
			if(game.getContent_pubdate()!=null){
	        	content_pubdate = "'"+sdf.format(game.getContent_pubdate())+"'";
	        }else{
	        	Date date = new Date();
				content_pubdate = "'"+sdf.format(date)+"'";
	        }
			String copyright_deadline = null;
	        if(game.getCopyright_deadline()!=null){
	        	copyright_deadline = "'"+sdf.format(game.getCopyright_deadline())+"'";
	        }else{
	        	copyright_deadline = "'2037-12-31'";
	        }
	        String service_code = b.ObjectToStringDB(game.getService_code());
			String ordered = b.ObjectToStringDB(game.getOrdered());
			String conten_info = b.ObjectToStringDB(game.getContent_info());
			String content_type = b.ObjectToStringDB(game.getContent_type());
			String content_keyword = b.ObjectToStringDB(game.getContent_keyword());
			String nowtime = b.getNowTime();
			String content_updateddate = b.ObjectToStringDB(nowtime);    
			String content_code = b.ObjectToStringDB(game.getContent_code());
			String pub_company = b.ObjectToStringDB(game.getPub_company());
	        String area = b.ObjectToStringDB(game.getArea());
	        String order_success_msg = b.ObjectToStringDB(game.getOrder_success_msg());
			
	        String strategy = b.ObjectToStringDB(game.getStrategy());
	        String language = b.ObjectToStringDB(game.getLanguage());
	        String online = b.ObjectToStringDB(game.getOnline());
	        String version = b.ObjectToStringDB(game.getVersion());
	        String cldc_version = b.ObjectToStringDB(game.getCldc_version());
	        String midp_version = b.ObjectToStringDB(game.getMidp_version());
	        String service_count = b.ObjectToStringDB(game.getService_count());
	        String billingPointChangeFlag = (String)(hashMap.get("billingPointChangeFlag"));
	        if(service_count == null || service_count.equals("") || service_count.equals("null"))
	        {
	        	service_count = b.ObjectToStringDB("0");
	        }
	        
//	        sql = sql + "user_id=" + user_id + ",";
	        sql = sql + "content_name=" + content_name + ",";
	        sql = sql + "genre_id=" + genre_id + ",";
	        sql = sql + "content_status=" + content_status + ","; 
	        sql = sql + "content_pubdate=" + content_pubdate + ",";
	        sql = sql + "service_code=" + service_code + ",";

	        sql = sql + "ordered=" + ordered + ",";
	        sql = sql + "conten_info=" + conten_info + ",";
	        sql = sql + "content_type=" + content_type + ",";
	        sql = sql + "content_keyword=" + content_keyword + ",";        
	        sql = sql + "content_updateddate=" + content_updateddate + ",";
	        sql = sql + "copyright_deadline=" + copyright_deadline + ",";
	        sql = sql + "pub_company=" + pub_company + ",";
	        sql = sql + "area=" + area + ",";
	        sql = sql + "content_code=" + content_code + ",";
	        sql = sql + "order_success_msg=" + order_success_msg + "";

	        sqlUpdateAuditApp = sqlUpdateAuditApp + "strategy=" + strategy + ",";
	        sqlUpdateAuditApp = sqlUpdateAuditApp + "language=" + language + ",";
	        sqlUpdateAuditApp = sqlUpdateAuditApp + "online=" + online + ",";     
	        sqlUpdateAuditApp = sqlUpdateAuditApp + "version=" + version + ",";
	        sqlUpdateAuditApp = sqlUpdateAuditApp + "cldc_version=" + cldc_version + ",";             
	        sqlUpdateAuditApp = sqlUpdateAuditApp + "midp_version=" + midp_version + ",";
	        sqlUpdateAuditApp = sqlUpdateAuditApp + "ordered=" + ordered + ",";
	        sqlUpdateAuditApp = sqlUpdateAuditApp + "service_count=" + service_count + "";
	                
	        sql = sql + " where contentid=" + content_id;
	        sqlUpdateAuditApp = sqlUpdateAuditApp + " where contentid=" + content_id;
	        
	        String temp=(String)hashMap.get("channelids");
	        String [] channelid=temp.split(",");
	        
	        //      update phase2  update news_contenttitle
	        String sqlUpdateNewsContentTitle = "update news_contenttitle set ";
//	        String contenticon = b.ObjectToString(hashMap.get("contenticon"));
	        String contenticon = SysProperty.getPrep("sysiconid_title");
	        if(contenticon == null || contenticon.equals(""))
	        	contenticon = "1";
	        String contenttext = "'"+InterUtil.rb.getString("src.gamename")+":"+b.ObjectToString(game.getContent_name())+"@"+InterUtil.rb.getString("src.devcompany")+":"+b.ObjectToString(game.getPub_company())
			+"@"+InterUtil.rb.getString("src.language")+":"+b.ObjectToString(game.getLanguage())+"@"+InterUtil.rb.getString("src.online")+":"+b.ObjectToString(game.getOnline())+"@"+InterUtil.rb.getString("src.version")+":"+
			b.ObjectToString(game.getVersion())+"@"+InterUtil.rb.getString("src.updatetime")+":"+nowtime+"@"+InterUtil.rb.getString("src.gameintro")+":"+
			b.ObjectToString(game.getContent_info())+"@"+InterUtil.rb.getString("src.gamesta")+":"+b.ObjectToString(game.getStrategy())+"'";
	        sqlUpdateNewsContentTitle = sqlUpdateNewsContentTitle + "contenttitle=" + content_name + ",";
	        sqlUpdateNewsContentTitle = sqlUpdateNewsContentTitle + "contenticon=" + contenticon + ",";
	        sqlUpdateNewsContentTitle = sqlUpdateNewsContentTitle + "contenttext=" + contenttext;
	        sqlUpdateNewsContentTitle = sqlUpdateNewsContentTitle + ",updatetime=now()  where contentid=" + content_id;
	        //---------
	        
	        ArrayList<String> sqlStrList = new ArrayList<String>();
	        String sqlDelBillingPoint = "delete from t_billingpoint_service where contentid="+content_id;
	        String sqlDelChannelAudit = "delete from t_channel_auditcontent where contentid="+content_id;
//	      phase2	
	        String sqlDelNewChannel = "delete from news_extends_channel_title where cid=(SELECT cid FROM news_contenttitle where contentid="+content_id+")";
	        
	        sqlStrList.add(sql);
	        sqlStrList.add(sqlUpdateNewsContentTitle);
	        sqlStrList.add(sqlUpdateAuditApp);        
	        sqlStrList.add(sqlDelChannelAudit);
	        sqlStrList.add(sqlDelNewChannel);
	        
	        //      phase2
	        String newChSql="insert into news_extends_channel_title(channleid,cid,contentstatus,istest,isnew)VALUES(";
	        for(int i=0;i<channelid.length;i++)
	        {
	        	sqlStrList.add(newChSql+"(select channleid from news_extends_channel where channel_id='"+channelid[i]+"')," +
	        			"(SELECT cid FROM news_contenttitle where contentid="+content_id+"),0,0,1)");
	        }
	        
	        int serviceCountNum = Integer.parseInt(service_count.replace("'", ""));
		        if(serviceCountNum > 0)
		        {
		        	sqlStrList.add(sqlDelBillingPoint);
			        for(int i = 1;i <= serviceCountNum; i++)
			        {
			        	StringBuffer sql_billingpoint_service = new StringBuffer();	        
				        sql_billingpoint_service.append("insert into t_billingpoint_service (contentid,billingpoint,comment,service_code) values (");
				        sql_billingpoint_service.append(content_id);
				        sql_billingpoint_service.append(",");
			        	sql_billingpoint_service.append("'"+i+"'");
			        	sql_billingpoint_service.append(",");
			        	sql_billingpoint_service.append("null");
			        	sql_billingpoint_service.append(",");
			        	sql_billingpoint_service.append(b.ObjectToStringDB(hashMap.get("service_point_" + i)));
			        	sql_billingpoint_service.append(")");
			        	sqlStrList.add(sql_billingpoint_service.toString());
			        }
		        }
//	        }
//	        String[] sqlStr = sqlStrList.toArray(new String[channelid.length+3+serviceCountNum]);
	        try {
	        	boolean bool=execTransaction(sqlStrList);
	            return bool;
	        } catch (Exception e) {
	        	log.info(" updateAuditContent fail !!!" +e.getMessage());
	            return false;
	        }
	    }
	 
	    
	    public boolean disableGame(String contentid)
		{
			ArrayList<String> sqlList = new ArrayList<String>();
			String sql = "update t_contents set content_status='disable',test_status='0' where contentid ='"+contentid+"'";
			sqlList.add(sql);
			sql = "update news_extends_channel_title set contentstatus=3 where cid=" +
					"(SELECT cid FROM news_contenttitle where contentid='"+contentid+"')";
			sqlList.add(sql);
			try {
				return execTransaction(sqlList);
			} catch (Exception e) {
				log.info(" disable game fail !!!" +e.getMessage());
				e.printStackTrace();
				return false;
			}
		}
	    
	    
	    public boolean subAuditGame(String content_id_list)
		{
			String updateSql = "";
			if(content_id_list!=null && !content_id_list.equals(""))
			{
				updateSql = "update t_contents set content_status='auditing', content_updateddate=now() where contentid in ("+content_id_list+")";
				try {
					return execUpdate(updateSql);
				} catch (Exception e) {
					log.info(" subAuditGame fail !!!" +e.getMessage());
					e.printStackTrace();
					return false;
				}
			}
			else
				return true;
		}
	    
	    
	  //modify phase2 如果审核通过 测试通过 则修改内容和栏目关联比表的contentstatus 修改时需要查询对应栏目的更新方式
	    public boolean auditGame(DataMap hashMap) {
	    	
	    	UtilsBean b = new UtilsBean();
	    	String content_id_list = (String)hashMap.get("content_id_list");
	    	String user_id = b.ObjectToStringDB(hashMap.get("user_id"));
	    	GameVo game=(GameVo)hashMap.get("game");
	    	
	        if(content_id_list!=null && !content_id_list.equals(""))
	        {
	        	String[] c_id_strList=content_id_list.split(",");
	        	for(String contentStr:c_id_strList)
		        {
	        		String[] idAndAuditStatus = contentStr.split("/");
		            String content_id = "'" + idAndAuditStatus[0] + "'";
		            String test_status = "'" + idAndAuditStatus[1] + "'";
		            ArrayList<String> sqlStrList = new ArrayList<String>();
		            
		        	//修改状态	            
		        	String sql1="update t_contents set content_status='"+game.getContent_status()+"',cause='"+game.getCause()+"',audituser="+user_id+" where contentid = "+content_id;
		        	sqlStrList.add(sql1);
		        	ArrayList chList = null;
		        	//发布 所有表 条件test_status=1 审核通过+测试通过
		        	try {
		        		
		        	if("pass".equals(game.getContent_status())&&test_status.equals("'1'"))
		        	{
		        		//转换图片 放在上线时做 这样可以避免重新上传文件后还需要审核的情况
			            String resourceid = this.scaleImage(content_id);
			            if(resourceid == null)
			            	return false;
			            else if(resourceid!=null && !resourceid.equals(""))
			            {
			            	String iconrid=this.queryOne("select max(n.rid) rid from news_resources n where n.name='"+resourceid+"'");
			            	String upConIconSql = "update news_contenttitle set contenticon="+iconrid+" where contentid="+content_id;
			            	sqlStrList.add(upConIconSql);
			            }
			            Object cid = this.getSingleResult("select cid from NewsContenttitle where contentid="+content_id);
		        		String tmpsql = "update news_extends_channel_title set contentstatus=2 where cid=" +cid;
		        		sqlStrList.add(tmpsql);
		        		//--------------
			        	
			        	//插入news_resources news_contenresource
			        	String sql10 = "insert into news_resources (resourcetype,name,size,newformat,fullpath) select 1,tr.resourceid,tr.size,tr.newformat,tr.fullpath " +
			        			"from t_resources tr,t_resource_content tra where tra.contentid="+content_id+" and tr.type='12' and tr.resourceid=tra.resourceid ";
			        	
			        	String sql11 = "insert into news_contenresource (cid,rid) select nc.cid,nr.rid from news_contenttitle nc,news_resources nr," +
			        			"t_resource_content tra,t_resources tr where tra.contentid="+content_id+" and tr.resourceid=tra.resourceid " +
			        					"and tr.type='12' and nr.resourcetype=1 and nc.contentid=tra.contentid and nr.name=tra.resourceid";
			        	
			        	sqlStrList.add(sql10);
			        	sqlStrList.add(sql11);
		        	}
		            
		            	this.execTransaction(sqlStrList);
		            } catch (Exception e) {
		            	log.info(content_id+" audit fail !!!" +e.getMessage());
		            	return false;
		            }
		        }
		    	return true;
		    	
	        }
	        else
	        	return false;
	        
	        
	    }  

	    public boolean testGame(DataMap hashMap) {
	    	UtilsBean b = new UtilsBean();
	    	
	    	String content_id_list = (String)hashMap.get("content_id_list");
	    	GameVo game=(GameVo)hashMap.get("game");
	    
	        if(content_id_list!=null && !content_id_list.equals(""))
	        {
	        	String[] c_id_strList=content_id_list.split(",");
	        	for(String contentStr:c_id_strList)
		        {
	        		String[] idAndAuditStatus = contentStr.split("/");
		            String content_id = "'" + idAndAuditStatus[0] + "'";
		            String content_status = "'" + idAndAuditStatus[1] + "'";
		            String user_id = b.ObjectToStringDB(hashMap.get("user_id"));
		            
		        	//修改状态	            
		        	String sql1="update t_contents set test_status='1' where contentid = "+content_id;
		        	//phase2 add update news_extends_channel_title set istest = 1
		        	String sqlNew="update news_extends_channel_title set istest=1 where cid =(SELECT cid FROM news_contenttitle where contentid= "+content_id +")";
		        	ArrayList<String> sqlStrList = new ArrayList<String>();
		        	sqlStrList.add(sql1);
		        	sqlStrList.add(sqlNew);
//		        	sqlStrList.add(sqlUpDateAuditAppContent);
		        	ArrayList chList = null;
		        	//发布 所有表 条件audit_status=1 审核通过+测试通过
		        	try {
		        	if("1".equals(game.getTest_status())&&content_status.equals("'pass'"))
		        	{
		        		//转换图片 放在上线时做 这样可以避免重新上传文件后还需要审核的情况
			            String resourceid = this.scaleImage(content_id);
			            if(resourceid == null)
			            	return false;
			            else if(resourceid!=null && !resourceid.equals(""))
			            {
			            	String upConIconSql = "update news_contenttitle set contenticon=(select max(rid) from news_resources where name='"+resourceid+"') where contentid="+content_id;
			            	sqlStrList.add(upConIconSql);
			            }
		        		
		        		String tmpsql = "update news_extends_channel_title set contentstatus=2 where cid=" +
							"(SELECT cid FROM news_contenttitle where contentid="+content_id+")";
		        		sqlStrList.add(tmpsql);
		        		//--------------
		        		
			        	String sql10 = "insert into news_resources (resourcetype,name,size,newformat,fullpath) select 1,tr.resourceid,tr.size,tr.newformat,tr.fullpath " +
	        				"from t_resources tr,t_resource_content tra where tra.contentid="+content_id+" and tr.type='12' and tr.resourceid=tra.resourceid ";
	        	
			        	String sql11 = "insert into news_contenresource (cid,rid) select nc.cid,nr.rid from news_contenttitle nc,news_resources nr," +
	        				"t_resource_content tra,t_resources tr where tra.contentid="+content_id+" and tr.resourceid=tra.resourceid " +
	        					"and tr.type='12' and nr.resourcetype=1 and nc.contentid=tra.contentid and nr.name=tra.resourceid";
	        	
			        	sqlStrList.add(sql10);
			        	sqlStrList.add(sql11);
		        	}
//		        	String [] sql = sqlStrList.toArray(new String[10]);

		           
		            	this.execTransaction(sqlStrList);
		            } catch (Exception e) {
		            	log.info(content_id+" test fail !!!"+e.getMessage());
		            	return false;
		            }
		        }
		    	return true;
		    	
	        }
	        else
	        	return false;
	        
	        
	    }
	    
	    public String scaleImage(String contentid)
		{
			String sql = "select t.resourceid,t.fullpath from t_resources t,t_resource_content trac" +
					" where t.type='12' and t.resourceid=trac.resourceid and trac.contentid="+contentid;
			List resList = null;
			String resourceid = "";
			try {
				resList = this.queryALLResultSet(sql);
			
				if(resList.size()>0)
				{
					HashMap<String,String> tmpMap = (HashMap)resList.get(0);
					resourceid = tmpMap.get("resourceid");
					String fullpath = tmpMap.get("fullpath");
					ImageScalee ims = new ImageScalee();
					String imageSizeScaleStr = SysProperty.getPrep("news_imagesizescale");
		        	String imageFormatScaleStr = SysProperty.getPrep("news_imageformatscale");
		        	if(imageFormatScaleStr == null || imageFormatScaleStr.equals(""))
		        		imageFormatScaleStr = "png";
					String[] imageSizeScaleAry = imageSizeScaleStr.split(","); 
					String[] imageFormatScaleAry = imageFormatScaleStr.split(","); 
					if(imageSizeScaleAry != null&&imageSizeScaleAry.length>0)
					{
						for(String imageSizeScale:imageSizeScaleAry)
						{
							String screenWidHei = imageSizeScale.split("@")[0];
							String picWidHei = imageSizeScale.split("@")[1];
							int screenWidth = Integer.parseInt(screenWidHei.split("x")[0]);
							int screenHeight = Integer.parseInt(screenWidHei.split("x")[1]);
							int width = Integer.parseInt(picWidHei.split("x")[0]);
							int height = Integer.parseInt(picWidHei.split("x")[1]);
							if(imageFormatScaleAry!=null && imageFormatScaleAry.length>0)
								for(String imageFormatScale:imageFormatScaleAry)
									ims.compressPicsScale(fullpath, width, height, imageFormatScale, screenWidth, screenHeight);
						}
					}
					String scaleFullPath = fullpath.replace(".", "-p.");
					sql = "insert into news_resources (name,newformat,fullpath) values('"+resourceid+"','"+imageFormatScaleStr+"','"+scaleFullPath+"')";
					this.execUpdate(sql);
				}
			} catch (Exception e) {
				log.info(" parse content icon fail !!!" +e.getMessage());
				e.printStackTrace();
				return null;
			}
			return resourceid;
		}
	    
	    
//	    public DataMap getContentById(String contentid) {
////	    	String sql = "select * from t_auditcontents c, t_auditapp_content tc WHERE c.contentid=tc.contentid  ";
//	        
//	    	String sql = "select au.*,gen.genre_name,p.service_code,p.price,p.price_type,tac.* from " +
//			" t_contents au,t_genre gen,t_service_info p,t_auditapp_content tac " +
//			" where au.genre_id=gen.genre_id and au.service_code=p.service_code and au.contentid = tac.contentid ";
//	        if (super.StringIsNull(contentid)) {
//	            sql = sql + " AND au.contentid='" + contentid + "'";
//	        }       
//
//	        try {
//	        	return null;
//	         //   return queryOneRow(sql);
//	        } catch (Exception e) {
//	        	log.info(" getContentById fail !!!" +e.getMessage());
//	            return null;
//	        }
//	    } 
	    
//	    public ArrayList getResouceByContentId(String contentid) {
//	    	String sql = "select tr.*,group_concat(ua_class_info) ua_class_info from t_contents tc , t_resources tr left join t_ua_class tuc on " +
//	    			"FIND_IN_SET(tuc.ua_class_id,tr.useragents) >0, t_resource_content rc " +
//	    			"WHERE rc.resourceid=tr.resourceid and tc.contentid=rc.contentid ";
//	        
//	        if (super.StringIsNull(contentid)) {
//	            sql = sql + " AND rc.contentid='" + contentid + "'";
//	        }
//	        sql = sql + " group by tr.resourceid";
//	        try {
//	            return queryALLResultSet(sql);
//	        } catch (Exception e) {
//	        	log.info(" getResouceByContentId fail !!!" +e.getMessage());
//	            return null;
//	        }
//	    }
	    
	    public boolean updateOrderMsg(DataMap hashMap)
	    {
	    	GameVo game=(GameVo)hashMap.get("game");
	    	String sql = "";
	    	if(super.StringIsNotNull(game.getContentid()))
	    	{
	    		sql = "update t_contents set order_success_msg='"+game.getOrder_success_msg()+"' where contentid='"+game.getContentid()+"'";
	    	}
	    	try {
	    		return execUpdate(sql);
	        } catch (Exception e) {
	        	log.info(" updateOrderMsg fail !!!" +e.getMessage());
	            return false;
	        }
	    }
	    
	    //add phase2 reset content to channel
	    public boolean resetConToChannel(DataMap hashMap)
	    {
	    	GameVo game=(GameVo)hashMap.get("game");
	    	UtilsBean b=new UtilsBean();
	    	String content_id = b.ObjectToStringDB(game.getContentid());
	    	String test_status = b.ObjectToString(game.getTest_status());
	    	String content_status = b.ObjectToString(game.getContent_status());
	    	String temp=(String)hashMap.get("channelids");
	        String [] channelid=temp.split(",");
			ArrayList<String> sqlStrList = new ArrayList<String>();
			String sqlDelChannelAudit = "delete from t_channel_auditcontent where contentid="+content_id;
			String sqlDelChannelContent = "";
			//如果审核通过测试通过 表示当前内容是已经发布的内容 在t_contents t_channel_contents里有对应的数据
			if(content_status.toLowerCase().equals("pass") && test_status.equals("1"))
			{
				sqlDelChannelContent = "delete from t_channel_contents where contentid="+content_id;
			}
			String sqlDelNewChannel = "delete from news_extends_channel_title where cid=(SELECT cid FROM news_contenttitle where contentid="+content_id+")";
			sqlStrList.add(sqlDelChannelAudit);
			if(sqlDelChannelContent.length()>0)
					sqlStrList.add(sqlDelChannelContent);
			sqlStrList.add(sqlDelNewChannel);
			String tempSql="insert into t_channel_auditcontent(contentid,channel_id)VALUES( "+content_id + ",";
			String tempPassSql="insert into t_channel_contents(contentid,channel_id)VALUES( "+content_id + ",";
			String newChSql="insert into news_extends_channel_title(channleid,cid,contentstatus,istest,isnew)VALUES(";
			
			try {
				for(int i=0;i<channelid.length;i++)
				{
					sqlStrList.add(tempSql+"'"+channelid[i]+"')");
					if(content_status.toLowerCase().equals("pass") && test_status.equals("1"))
					{
						sqlStrList.add(tempPassSql+"'"+channelid[i]+"')");
					}
					String chupdatetimer = queryOne("select updatetimer from news_extends_channel where channel_id='"+channelid[i]+"'");
					if(chupdatetimer != null && chupdatetimer.equals("0"))
						sqlStrList.add(newChSql+"(select channleid from news_extends_channel where channel_id='"+channelid[i]+"')," +
								"(SELECT cid FROM news_contenttitle where contentid="+content_id+"),1,"+test_status+",1)");
					else
						sqlStrList.add(newChSql+"(select channleid from news_extends_channel where channel_id='"+channelid[i]+"')," +
								"(SELECT cid FROM news_contenttitle where contentid="+content_id+"),2,"+test_status+",1)");
				}
				return execTransaction(sqlStrList);
	        } catch (Exception e) {
	        	log.info(" resetConToChannel fail !!!" +e.getMessage());
	            return false;
	        }
	    }
	    
	    
	    public boolean insertReUploadResource(DataMap hashMap) {
	    	UtilsBean b=new UtilsBean();
	        StringBuffer sqlB = new StringBuffer();
	        String resource_id = b.ObjectToStringDB(hashMap.get("resource_id"));
	        Object content_id = b.ObjectToStringDB(hashMap.get("content_id"));
	        String name = b.ObjectToStringDB(hashMap.get("name"));
	        long size = b.getlong(hashMap.get("size"));
	        String type = b.ObjectToStringDB(hashMap.get("type"));
	        String spcode = b.ObjectToStringDB(hashMap.get("spcode"));
	        String url = b.ObjectToStringDB(hashMap.get("url"));
	        String format = b.ObjectToStringDB(hashMap.get("format"));
	        String distributorid = b.ObjectToStringDB(hashMap.get("distributorid"));
	        String newformat = SysProperty.getPrep("news_imageformat");
	        if(newformat == null || newformat.equals(""))
	        	newformat = "jpg";
	        if(format.lastIndexOf("_")>0)
	        	//'_100_100_jpg'.substring==>jpg'
	        	format = "'"+format.substring(format.lastIndexOf("_")+1);
	        
	        String curdate = (new java.text.SimpleDateFormat("yyyyMM")).format(new Date());
	        String fullpath = SysProperty.getPrep("uploadpath")+"/"+spcode.replace("'", "")+"/"+type.replace("'", "")+"/"+curdate+"/"+url.replace("'", "")+"."+format.replace("'", "");
	        String sqlInsertResource = "insert into t_resources (resourceid,contentid,name,size,type,spcode,url,format,distributorid,newformat,fullpath) VALUES ( ";
	        sqlB.append(sqlInsertResource);        
	        sqlB.append(resource_id).append(",");
	        sqlB.append(content_id).append(",");
	        sqlB.append(name).append(",");
	        sqlB.append(size).append(",");
	        sqlB.append(type).append(",");
	        sqlB.append(spcode).append(",");
	        sqlB.append(url).append(",");
	        sqlB.append(format).append(",");
	        sqlB.append(distributorid).append(",");
	        sqlB.append("'"+newformat+"'").append(",");
	        sqlB.append("'"+fullpath+"'").append(")");
	        String sqlInsertAuditContentResource = "insert into  t_resource_content  values (" + resource_id +"," + content_id + ")";
	        hashMap = new DataMap();
	        ArrayList<String> sqlStrList = new ArrayList<String>();
	        sqlStrList.add(sqlB.toString());
	        sqlStrList.add(sqlInsertAuditContentResource);
	        String [] sql = sqlStrList.toArray(new String[10]);

	        try {
	        	return execTransaction(sql);
	        } catch (Exception e) {
	        	log.info(" insertReUploadResource fail !!!" +e.getMessage());
	            return false;
	        }
	    }    
	    
	    public boolean delResourceById(String resourceid,String content_id)  {
	    	ArrayList<String> sqlStrList = new ArrayList<String>();
	        String sql1 = "";
	        String sql2 = "";
	        String sqlInsert = "";
	        String deleteNews = "";
	        if(resourceid != null && !resourceid .equals(""))
	        {
	        	sqlInsert = "insert into t_resourcedelete (spcode,type,url,format) (select tr.spcode,tr.type,tr.url,tr.format from t_resources tr where tr.resourceid='" + resourceid + "')";
	        	sqlStrList.add(sqlInsert);
	        	sql1 = "delete from t_resources where resourceid='" + resourceid + "'";
	        	sqlStrList.add(sql1);
	        	deleteNews = "delete from news_resources where name='"+ resourceid + "'";
	        	sqlStrList.add(deleteNews);
	        }
	        sql2 = "delete from t_resource_content where resourceid='" + resourceid + "'";
	        if(content_id != null && !content_id .equals(""))
	        {
	        	sql2 = sql2 + " and contentid='" + content_id +"'";
	        }
	        sqlStrList.add(sql2);
	        try {
	        	boolean bool=execTransaction(sqlStrList);
	            return bool;
	        } catch (Exception e) {
	        	log.info(" delResourceById fail !!!" +e.getMessage());
	            return false;
	        }
	    }    
	    
    public DataMap getResource(String  resourceid) {

//    	String sql = "select * from t_resources where resourceid= '" + resourceid + "'";
        try {
        	  return null;
            //return queryOneRow(sql);
        } catch (Exception e) {
        	log.info(" getResource fail !!!" +e.getMessage());
            return null;
        }
    }
    public ArrayList getMobileCompany(DataMap hashMap) {
        String sql = "SELECT t.com_id,t.com_name FROM t_mobile_company_info t where 1=1 ";
        try {
            return queryALLResultSet(sql);
        } catch (Exception e) {
        	log.info(" getMobileCompany fail !!!" +e.getMessage());
            return null;
        }
    }
    
    public ArrayList getCurrentUaClassList(String resourceid) {
    	String sql = "";
//    	if(resourceid != null && !resourceid.equals(""))
//        	sql = "select * FROM t_ua_class where FIND_IN_SET(ua_class_id,( SELECT useragents FROM t_resources  where resourceid='"+resourceid+"')) >0 ";
        try {
        	return null;
//            return queryALLResultSet(sql);
        } catch (Exception e) {
        	log.info(" get current uaclass list fail !!!" +e.getMessage());
        	return null;
        }
    }
	    
    public ArrayList getUaClass(String comid) {
        String sql = "SELECT t.UA_CLASS_ID,t.UA_CLASS, t.ua_class_info FROM t_ua_class t where com_id= " + comid;
        
        try {
            return queryALLResultSet(sql);
        } catch (Exception e) {
        	log.info(" getUaClass fail !!!" +e.getMessage());
            return null;
        }
    }
    
    public String getCurrentUaClass(String resourceid) {
    	String sql = "";
    	if(resourceid != null && !resourceid.equals(""))
        	sql = "SELECT useragents FROM t_resources t where resourceid='" + resourceid + "'";
        try {
            return queryOne(sql);
        } catch (Exception e) {
        	log.info(" get current uaclass id fail !!!" +e.getMessage());
        	return "";
        }
    }
    
    public boolean updateResourceUa(String useragent,String resourceid) {
        String sql = "update t_resources set useragents='"+useragent+"' where resourceid='" + resourceid + "'";
        try {
            return execUpdate(sql);
        } catch (Exception e) {
        	log.info(" updateResourceUa fail !!!" +e.getMessage());
        	return false;
        }
    }
    
    
    public boolean delUaclassByResid(String resourceid,String uaclassid)
    {
    	String sql = "";
    	if(resourceid != null && !resourceid.equals(""))
        	sql = "select useragents FROM t_resources where resourceid ='"+resourceid+"'";
    	try {
	    	String useragents = queryOne(sql);
	    	if(uaclassid != null)
	    	{
	    		String uaclassidstr = uaclassid + ",";
	    		String uaclsidstr = ","+uaclassid;
	    		if(useragents.contains(uaclassidstr))
	    			useragents = useragents.replace(uaclassidstr, "");
	    		else if(useragents.contains(uaclsidstr))
	    			useragents = useragents.replace(uaclsidstr, "");
	    		else if(useragents.contains(uaclassid))
	    			useragents = useragents.replace(uaclassid, "");
	    	}
	    	sql = "update t_resources set useragents='"+useragents+"' where resourceid='"+resourceid+"'";
	    	return execUpdate(sql);
        } catch (Exception e) {
        	log.info(" delUaclassByResid fail !!!" +e.getMessage());
        	return false;
        }
        
    }
    
    
	 public ArrayList getPriceAll(DataMap hashMap) {
		 String userids=(String)hashMap.get("userids");
	        String sql = "select p.serviceid,p.servicename,p.service_code,p.price,p.price_type,p.servicetype,p.access_no,p.port_type,p.content,p.content_type,p.processClass,p.carrier,p.spnumber,p.order_success_msg,p.ctrmand_cmd,p.ctrmand_no,p.starttime" +
	        		" from t_service_info p,t_user_prices up where p.service_code=up.service_code ";
	        
	        Object employee_id = hashMap.get("employee_id");
	        Object role_id = hashMap.get("role_id");
	        if(role_id != null)
	        {
		        if (!role_id.equals("") && StringIsNull(employee_id)) {
		            sql = sql + " AND employee_id='" + employee_id + "'";
		        }
	        }else if(userids!=null){
	        	sql = "select distinct p.serviceid,p.servicename,p.service_code,p.price,p.price_type,p.servicetype,p.access_no,p.port_type,p.content,p.content_type,p.processClass,p.carrier,p.spnumber,p.order_success_msg,p.ctrmand_cmd,p.ctrmand_no,p.starttime" +
	        			" from t_service_info p,t_user_prices up where p.service_code=up.service_code ";
	        	sql = sql + " AND employee_id in (SELECT employee_id FROM t_user where user_id in (" + userids + "))";
	        }
	        else if(role_id == null || role_id.equals(""))
	        {
	        	sql = "select p.serviceid,p.servicename,p.service_code,p.price,p.price_type,p.servicetype,p.access_no,p.port_type,p.content,p.content_type,p.processClass,p.carrier,p.spnumber,p.order_success_msg,p.ctrmand_cmd,p.ctrmand_no,p.starttime" +
	        			" from t_service_info p ";
	        }
	        try {
	            return queryALLResultSet(sql);
	        } catch (Exception e) {
	        	log.info(" getPriceAll fail !!!" +e.getMessage());
	            return null;
	        }
	    }
	 
	 //只取计费点业务
	    public ArrayList getPriceOrder(DataMap hashMap) {
	    	String userids=(String)hashMap.get("userids");
	    	
	        String sql = "select p.serviceid,p.servicename,p.service_code,p.price,p.price_type,p.servicetype,p.access_no,p.port_type,p.content,p.content_type,p.processClass,p.carrier,p.spnumber,p.order_success_msg,p.ctrmand_cmd,p.ctrmand_no,p.starttime" +
	        		" from t_service_info p,t_user_prices up where p.servicetype='6' and p.service_code=up.service_code ";
	        
	        Object employee_id = hashMap.get("employee_id");
	        Object role_id = hashMap.get("role_id");
	        if(role_id != null)
	        {
		        if (!role_id.equals("") && StringIsNull(employee_id)) {
		            sql = sql + " AND employee_id='" + employee_id + "'";
		        }
	        }else if(userids!=null){
	        	sql = "select distinct p.serviceid,p.servicename,p.service_code,p.price,p.price_type,p.servicetype,p.access_no,p.port_type,p.content,p.content_type,p.processClass,p.carrier,p.spnumber,p.order_success_msg,p.ctrmand_cmd,p.ctrmand_no,p.starttime" +
	        			" from t_service_info p,t_user_prices up where p.servicetype='6' and p.service_code=up.service_code ";
	        	sql = sql + " AND employee_id in (SELECT employee_id FROM t_user where user_id in (" + userids + "))";
	        }else if(role_id == null || role_id.equals(""))
	        {
	        	sql = "select p.serviceid,p.servicename,p.service_code,p.price,p.price_type,p.servicetype,p.access_no,p.port_type,p.content,p.content_type,p.processClass,p.carrier,p.spnumber,p.order_success_msg,p.ctrmand_cmd,p.ctrmand_no,p.starttimep.serviceid,p.servicename,p.service_code,p.price,p.price_type,p.servicetype,p.access_no,p.port_type,p.content,p.content_type,p.processClass,p.carrier,p.spnumber,p.order_success_msg,p.ctrmand_cmd,p.ctrmand_no,p.starttime" +
	        			" from t_service_info p where p.servicetype='6'";
	        }
	        
	        try {
	            return queryALLResultSet(sql);
	        } catch (Exception e) {
	        	log.info(" getPriceOrder fail !!!" +e.getMessage());
	            return null;
	        }
	    }
	    
	    
	    /*public ArrayList getChannelList(DataMap hashMap) {
	        String sql = "select ch.* from t_channels ch WHERE 1=1 " +
	        		"and channel_type='"+BookConfig.channel_type_game+"' " +
	        		//"and status='"+BookConfig.channel_status_enable+"' " +
	        		"and (function_name='"+BookConfig.channel_song+"' OR function_name='"+BookConfig.channel_last+"')";
	        Object employee_id = hashMap.get("employee_id");
	        Object role_id = hashMap.get("role_id");
	        if(role_id != null)
	        {
		        if (!role_id.equals("") && StringIsNull(employee_id)) {
		            sql = "select ch.* from t_channels ch,t_user_channels uc WHERE 1=1 " +
		            "and channel_type='"+BookConfig.channel_type_game+"' " +
		            "and ch.channel_id=uc.channel_id " +
		            //"and status='"+BookConfig.channel_status_enable+"' " +
		            "and (function_name='"+BookConfig.channel_last+"' OR function_name='"+BookConfig.channel_song+"') " +
		            "and uc.employee_id='" + employee_id + "'";
		        }
	        }
	        try {
	            return queryALLResultSet(sql);
	        } catch (Exception e) {
	        	log.info(" getChannelList fail !!!" +e.getMessage());
	            return null;
	        }
	        
	    }*/
	    
    public ArrayList getGenreAll() {
    	 return null;
//        String sql = "select * from t_genre where conent_type='3' or conent_type='10'";
//        try {
//            return queryALLResultSet(sql);
//        } catch (Exception e) {
//        	log.info(" getGenreAll fail !!!" +e.getMessage());
//            return null;
//        }
    }
	    
    public List<TGenre> getGenreAll2()
	{
		String hql = "SELECT tg FROM TGenre tg " ;
		//open
			hql+=	"where tg.conentType='9' or tg.conentType='10'" ;
		return getQueryList(hql);
	}
	
    
    public ArrayList findNotChooseChannel(DataMap hashMap) {
    	String content_id=(String)hashMap.get("content_id");
    	String roleId=(String)hashMap.get("role_id");
    	String userId=(String)hashMap.get("user_id");
    	String userids=(String)hashMap.get("userids");
		//root
		String findSql = "select tc.channel_id,tc.channel_name from t_channels tc WHERE 1=1 " +
				//will open
				//" and status='"+BookConfig.channel_status_enable+"' " +
				" and channel_type='"+BookConfig.channel_type_game+"' " + 
				" AND (tc.function_name='LAST' OR tc.function_name='CHANNELSONG') ";
		//normal user
		if(roleId != null && !roleId.equals(""))
        {
			findSql = "select tc.channel_id,tc.channel_name from t_channels tc,t_user_channels uc WHERE tc.channel_id=uc.channel_id " +
            		//" and status='"+BookConfig.channel_status_enable+"'" +
            		" and channel_type='"+BookConfig.channel_type_game+"' " + 
            		" and (function_name='"+BookConfig.channel_last+"' OR function_name='"+BookConfig.channel_song+"')  " +
            		" and uc.employee_id=(SELECT employee_id FROM t_user where user_id='" + userId + "')";
        }else if(userids!=null){
        	findSql = "select distinct tc.channel_id,tc.channel_name from t_channels tc,t_user_channels uc WHERE tc.channel_id=uc.channel_id " +
    		//" and status='"+BookConfig.channel_status_enable+"'" +
    		" and channel_type='"+BookConfig.channel_type_game+"' " + 
    		" and (function_name='"+BookConfig.channel_last+"' OR function_name='"+BookConfig.channel_song+"')  " +
    		" and uc.employee_id in (SELECT employee_id FROM t_user where user_id in (" + userids + "))";
        }
		findSql = findSql + " and tc.channel_id not in (select tc.channel_id from t_channels tc,news_extends_channel nec," +
				"news_extends_channel_title nct,news_contenttitle nc where (function_name='LAST' OR function_name='CHANNELSONG') and nc.contentid='"+content_id+"' and nc.cid=nct.cid and " +
						"nec.channel_id=tc.channel_id and nec.channleid=nct.channleid )";
		
		try {
			return queryALLResultSet(findSql.toString());
		} catch (Exception e) {
			log.info(" findNotChooseChannel fail !!!" +e.getMessage());
			return null;
		}
	}
    
    public ArrayList getChooseChannel(DataMap hashMap) {
        String sql = "select tc.channel_id,tc.channel_name from t_channels tc,news_extends_channel nec,news_extends_channel_title nct,news_contenttitle nc ";
        sql=sql+"WHERE   (function_name='"+BookConfig.channel_last+"' OR function_name='"+BookConfig.channel_song+"') ";
        sql=sql+" and nc.cid=nct.cid  and nec.channel_id=tc.channel_id and nec.channleid=nct.channleid ";
        Object content_id = hashMap.get("content_id");
        if (super.StringIsNull(content_id)) {
            sql = sql + " and nc.contentid='" + content_id + "'";
        }
        System.out.println("sql:"+sql);
        try {
            return queryALLResultSet(sql);
        } catch (Exception e) {
        	log.info(" getChooseChannel fail !!!" +e.getMessage());
            return null;
        }
    }
    
    
    public String getSpcodeByContentid(String content_id) {
        String sql = "";        
        if (super.StringIsNull(content_id)) {
        	sql = "SELECT te.sp_code FROM t_user tu , t_employee te,t_contents tc where " +
    		"tu.employee_id=te.employee_id and  tu.user_id =tc.user_id and tc.contentid='" + content_id + "'";
        }
        try {
            String spcode = queryOne(sql);
            if(spcode == null)
            		spcode = "00";
            return spcode;
        } catch (Exception e) {
        	log.info(" getSpcodeByContentid fail !!!" +e.getMessage());
            return null;
        }
    }  
    
//    public ArrayList getChooseResource(DataMap hashMap) {
//    	String sql = "";
//    	Object content_id = hashMap.get("content_id");
//    	if (super.StringIsNull(content_id)) {
//    		sql = "select group_concat(ua_class_info) ua_class_info,tr.* from t_resources tr left join t_ua_class tuc on FIND_IN_SET(tuc.ua_class_id,tr.useragents) >0, " +
//    				"t_resource_content trc where trc.resourceid = tr.resourceid and trc.contentid='" + content_id + "' group by tr.resourceid";
//        }
//        
//        try {
//            return queryALLResultSet(sql);
//        } catch (Exception e) {
//        	log.info(" getChooseResource fail !!!" +e.getMessage());
//            return null;
//        }
//    }
    
//    public ArrayList getBillingPoint(DataMap hashMap) {
//        String sql = "select bp.* from t_billingpoint_service bp where 1=1 ";;
//        
//        Object content_id = hashMap.get("content_id"); 
//        if (super.StringIsNull(content_id)) {
//            sql = sql + " and contentid='" + content_id + "'";
//        }
//        
//        try {
//            return queryALLResultSet(sql);
//        } catch (Exception e) {
//        	log.info(" getBillingPoint fail !!!" +e.getMessage());
//            return null;
//        }
//    }
    
    
//    public DataMap getBook(DataMap hashMap) {
//        String sql = "select au.*,gen.genre_name,p.service_code,p.price,p.price_type,p.processClass,tac.* from " +
//        		" t_contents au,t_genre gen,t_service_info p,t_auditapp_content tac " +
//        		" where au.genre_id=gen.genre_id and au.service_code=p.service_code and au.contentid = tac.contentid ";
//        Object content_id = hashMap.get("content_id");
//        if (super.StringIsNull(content_id)) {
//            sql = sql + " and au.contentid='" + content_id + "'";
//        }
//        try {
//        	 return null;
//          //  return queryOneRow(sql);
//        } catch (Exception e) {
//        	log.info(" getBook fail !!!" +e.getMessage());
//            return null;
//        }
//    }  
    
    public boolean checkContentCode(String contentcode,String contentid,String userid) 
    {
    	String sql = "select contentid from t_contents t,t_employee te,t_user tu where t.content_code='"+contentcode+"' and " +
    			"t.user_id=tu.user_id and tu.employee_id=te.employee_id and te.sp_code=" +
    			"(select e.sp_code from t_user u,t_employee e where e.employee_id=u.employee_id and u.user_id='"+userid+"')";
        if(contentid != null && !contentid.equals(""))
        {
        	sql = sql+" and t.contentid != '"+contentid+"' ";
        }
        try {
            return queryExist(sql);
        } catch (Exception e) {
        	log.info(" checkContentCode fail !!!" +e.getMessage());
        	return true;
        }
    }
    
	/**
	 * 用户可支配的栏目
	 * @param hashMap
	 * @return
	 */
	public ArrayList<DataMap> findAllLastChannel(Object roleId, String userId,String userids) {
		//root
		String findSql = "select  ch.channel_id  ,ch.service_code,ch.channel_name,ch.channel_comment ,ch.function_name,ch.STATUS ,ch.ordered ,ch.created_date" +
				",ch.previous_id ,ch.primal_id ,ch.LEVEL ,ch.channel_type  ,ch.channel_hot_topics ,ch.channel_classifying_label" +"  from t_channels ch WHERE 1=1 " +
				//will open
				//" and status='"+BookConfig.channel_status_enable+"'" +
				" and channel_type='"+BookConfig.channel_type_game+"' " + 
				" AND (function_name='"+BookConfig.channel_last+"' OR function_name='"+BookConfig.channel_song+"') ";
		//normal user
		if(roleId != null && !roleId.equals(""))
		{
			findSql = "select  ch.channel_id  ,ch.service_code,ch.channel_name,ch.channel_comment ,ch.function_name,ch.STATUS ,ch.ordered ,ch.created_date" +
				",ch.previous_id ,ch.primal_id ,ch.LEVEL ,ch.channel_type  ,ch.channel_hot_topics ,ch.channel_classifying_label" +"  from t_channels ch,t_user_channels uc WHERE ch.channel_id=uc.channel_id " +
		    		//" and status='"+BookConfig.channel_status_enable+"'" +
		    		" and channel_type='"+BookConfig.channel_type_game+"' " + 
		    		" and (function_name='"+BookConfig.channel_last+"' OR function_name='"+BookConfig.channel_song+"')  " +
		    		" and uc.employee_id=(SELECT employee_id FROM t_user where user_id='" + userId + "')";
		}else if(userids!=null){
			findSql = "select distinct  ch.channel_id  ,ch.service_code,ch.channel_name,ch.channel_comment ,ch.function_name,ch.STATUS ,ch.ordered ,ch.created_date" +
				",ch.previous_id ,ch.primal_id ,ch.LEVEL ,ch.channel_type  ,ch.channel_hot_topics ,ch.channel_classifying_label" +"  from t_channels ch,t_user_channels uc WHERE ch.channel_id=uc.channel_id " +
	    		//" and status='"+BookConfig.channel_status_enable+"'" +
	    		" and channel_type='"+BookConfig.channel_type_game+"' " + 
	    		" and (function_name='"+BookConfig.channel_last+"' OR function_name='"+BookConfig.channel_song+"')  " +
	    		" and uc.employee_id in (SELECT employee_id FROM t_user where user_id in (" + userids + "))";
		}
		
		try {
			return this.queryALLResultSet(findSql.toString());
		} catch (Exception e) {
			logger.error(" findAllLastChannel fail !!!" +e.getMessage());
			return null;
		}
	}
	
	//add 1119 select channel update
    public DataMap buildLastChannelMap()
    {
    	String sql = "SELECT channel_id,channel_name,function_name,previous_id FROM t_channels t";
    	HashMap<String,String> childIdAndPreiousId = new HashMap<String,String>();
    	HashMap<String,String> idAndName = new HashMap<String,String>();
    	DataMap result = new DataMap();
    	List chList = null;
    	try {
			chList = queryALLResultSet(sql);
		} catch (Exception e) {
			log.info(" java bean buildChChildIdAndPreviousIdMap fail !!!" +e.getMessage());
			e.printStackTrace();
			return null;
		}
		//首先建立两个map准备数据
		for(int i=0;i<chList.size();i++)
		{
			HashMap hashMap = (HashMap)chList.get(i);
			String channel_id = (String)hashMap.get("channel_id");
			String chName = (String)hashMap.get("channel_name");
			String fnName = (String)hashMap.get("function_name");
			String previous_id = (String)hashMap.get("previous_id");
			//先将id和name装入map
			idAndName.put(channel_id, chName);
			//channel如果是normal或者first,就装入map,key是channel_id,value是
			if(fnName.equals(BookConfig.channel_first) || fnName.equals(BookConfig.channel_normal))
			{
				childIdAndPreiousId.put(channel_id, previous_id);
			}
		}
		//build map,key:channleid value:previousid+name
		for(int i=0;i<chList.size();i++)
		{
			HashMap hashMap = (HashMap)chList.get(i);
			String channel_id = (String)hashMap.get("channel_id");
			String chName = (String)hashMap.get("channel_name");
			String fnName = (String)hashMap.get("function_name");
			String previous_id = (String)hashMap.get("previous_id");
			//如果是normal或者first,就装入map,key是channel_id,value是
			if(fnName.equals(BookConfig.channel_last) || fnName.equals(BookConfig.channel_song))
			{
				String previousChName = idAndName.get(previous_id);
				chName = chName+"="+previousChName;
				chName = getValue(childIdAndPreiousId,idAndName,previous_id,chName);
				//最上一级的频道名称必然是news,把news过滤掉
				chName = chName.substring(0,chName.lastIndexOf("="));
				String[] tmp = chName.split("=");
				String value = "";
				for(int j=tmp.length-1;j>=0;j--)
				{
					value=value+tmp[j]+"--";
				}
				value = value.substring(0,value.length()-2);
				result.put(channel_id, value);
			}
		}
    	return result;
    }
    
    private String getValue(HashMap<String,String> idmap,HashMap<String,String> namemap,String key,String result)
    {
    	String parentid = idmap.get(key);
    	String parentname = namemap.get(parentid);
    	if((key != null && parentid!=null) && !parentid.equals(key))
    	{
    		result = result+"="+parentname;
    		return getValue(idmap,namemap,parentid,result);
    	}
    	else
    	{
    		return result;
    	}
    }
}
